import { getNewsByIdAPI } from '../../api/news';
import { NEWS_SAVE_LIST } from './actionTypes';

export const getNewsByIdAction = (payload) => {
  // action 中，
  // 返回 {type:'add'}是同步
  // 返回函数，是异步
  return async (dispatch) => {
    const res = await getNewsByIdAPI(payload);
    console.log('res -----> ', res);
    dispatch({ type: NEWS_SAVE_LIST, payload: res.data.results });
  };
};
